package com.example.tool.util;

import org.apache.commons.lang3.StringUtils;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

public class ToolUtil {

    /**
     * track_first = {
     * '中通': ['78', '73', '76'],
     * '顺丰': 'SF',
     * '圆通': 'YT',
     * '申通': '77',
     * '韵达': ['46', '43', '32', '31'],
     * 'EMS': ['12', '98', '13'],
     * '京东': 'JD',
     * '极兔': 'JT',
     * '菜鸟': '62',
     * }
     *
     * @param args
     * @throws UnsupportedEncodingException
     */
    private static Map<String, String> mailData = new HashMap<>();

    static {
        mailData.put("ZT", "中通");
        mailData.put("SF", "顺丰");
        mailData.put("YT", "圆通");
        mailData.put("ST", "顺丰");
        mailData.put("YD", "韵达");
        mailData.put("EMS", "EMS");
        mailData.put("JD", "京东");
        mailData.put("JT", "极兔");
        mailData.put("CN", "菜鸟");
    }


    public static void main(String[] args) throws UnsupportedEncodingException {
        System.out.println();
    }

    public static String judgeMailType(String mailNo) {
        String mailNoType = "";
        String mailNoPrefix = "";
        if (StringUtils.isNotBlank(mailNo) && mailNo.length() > 3) {
            mailNoPrefix = mailNo.substring(0, 2).toUpperCase();
        }
        switch (mailNoPrefix) {
            case "78":
            case "73":
            case "76":
                mailNoType = "ZT";
                break;//中通
            case "SF":
                mailNoType = "SF";
                break;//顺丰
            case "YT":
                mailNoType = "YT";
                break;//圆通
            case "77":
                mailNoType = "ST";
                break;//申通
            case "46":
            case "43":
            case "32":
            case "31":
                mailNoType = "YD";
                break;//韵达
            case "12":
            case "98":
            case "13":
                mailNoType = "EMS";
                break;//EMS
            case "JD":
                mailNoType = "JD";
                break;//京东
            case "JT":
                mailNoType = "JT";
                break;//极兔
            case "62":
                mailNoType = "CN";
                break;//菜鸟
            default:
                break;
        }
        return mailNoType;
    }

}
